<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>json</title>
</head>

<body>
	<h1>json</h1>
	<script type="text/javascript">
		var n1 = 1;
		n1 = "1";
		n1 = JSON.parse(n1);
		console.info(n1 + " " + typeof (n1));
		var b1 = true;
		b1 = "false";
		b1 = JSON.parse(b1);
		console.info(b1 + " " + typeof (b1));

		var s1 = "ab\"c";
		s1 = '"ab\\"c"';
		s1 = JSON.parse(s1);
		console.info(s1);
		var s2 = 'ab\'c';
		s2 = "'ab\\'c'";
		// s2 = JSON.parse(s2);//不支持
		console.info(s2);

		var nu1 = null;
		nu1 = "null";
		nu1 = JSON.parse(nu1);
		console.info(nu1 + " " + typeof (nu1));
		var un1 = undefined;
		un1 = "undefined";
		// un1 = JSON.parse(un1);//不支持
		console.info(un1 + " " + typeof (un1));

		var obj1 = new Object();
		obj1.a = 1;
		obj1["b"] = "aa";
		console.info(obj1);
		console.info(JSON.stringify(obj1));
		console.info(JSON.stringify(obj1, null, "\t"));

		var obj2 = { a: 2, b: "bb" };
		obj2 = `{a:2,b:"bb"}`;
		// obj2 = JSON.parse(obj2);//不支持
		console.info(obj2);

		var obj3 = { "a": 3, "b": "cc" };
		obj3 = `{"a":3,"b":"cc"}`;
		obj3 = JSON.parse(obj3);
		console.info(obj3);

		var arr1 = new Array();
		arr1[0] = "aa";
		arr1[10] = true;
		console.info(arr1);
		console.info(JSON.stringify(arr1));

		var arr2 = ["bb", null, false];
		arr2 = `["bb",null,false]`;
		arr2 = JSON.parse(arr2);
		console.info(arr2);

		var classInfo = {
				"name":"java1班",
				"num":1,
				"isJava":true,
				"list":[
					{
						"name":"张三",
						"age":18,
						"sex":true
					},{
						"name":"李四",
						"age":20,
						"sex":false
					}
				]
			};

			classInfo = `{
				"name":"java1班",
				"num":1,
				"isJava":true,
				"list":[
					{
						"name":"张三",
						"age":18,
						"sex":true
					},{
						"name":"李四",
						"age":20,
						"sex":false
					}
				]
			}`;

			console.info(classInfo);

			classInfo = JSON.parse(classInfo);

			console.info(classInfo);
			console.info(classInfo.list[0].name);

			console.info(JSON.stringify(classInfo));
			console.info(JSON.stringify(classInfo,null,"\t"));
	</script>
</body>

</html>